from telnetlib import DO
from manim import *
from numpy import flip, insert

LV,QL,QH,JH='#75cfb8','#bbdfc8','#f0e5d8','#ffc478'
class LineTip(ArrowTip, Line):
    def __init__(self, length=0.2, **kwargs):
        Line.__init__(self,stroke_width=20,end=0.98*LEFT, **kwargs)
        self.stretch_to_fit_height(length)

class p1(MovingCameraScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        l1=Line(UP*2,DOWN*2).set_stroke(width=30).shift(LEFT*3).set_color(LV)
        l2=Line(UP*2,DOWN*2).set_stroke(width=30).shift(RIGHT*3).set_color(LV)
        l0=Line(LEFT*4,RIGHT*4).shift(DOWN*2).set_color(JH)
        da=DoubleArrow(LEFT*3,RIGHT*3,tip_shape_start=LineTip,tip_shape_end=LineTip).next_to(l0,DOWN)
        cb=CubicBezier(l1.get_top(),[-1,-2,0],[1,-2,0],l2.get_top()).set_color(JH)
        da_20=DoubleArrow(cb.point_from_proportion(0.5),l0.get_center(),tip_shape_start=LineTip,tip_shape_end=LineTip)
        self.add(l0,l1,l2,cb,da,da_20,
            MathTex('?').next_to(da,DOWN),
            MathTex('50m').next_to(l1,LEFT,buff=0.3),
            MathTex('50m').next_to(l2,buff=0.3),
            MathTex('80m'),
            MathTex('20m').next_to(da_20)
        )
        self.wait()

class p2(MovingCameraScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        l1=Line(UP*2,DOWN*2).set_stroke(width=30).shift(LEFT*3).set_color(LV)
        l2=Line(UP*2,DOWN*2).set_stroke(width=30).shift(RIGHT*3).set_color(LV)
        l0=Line(LEFT*4,RIGHT*4).shift(DOWN*2).set_color(JH)
        da=DoubleArrow(LEFT*3,RIGHT*3,tip_shape_start=LineTip,tip_shape_end=LineTip).next_to(l0,DOWN)
        cb=CubicBezier(l1.get_top(),[-1,-2,0],[1,-2,0],l2.get_top()).set_color(JH)
        da_20=DoubleArrow(cb.point_from_proportion(0.5),l0.get_center(),tip_shape_start=LineTip,tip_shape_end=LineTip)
        self.add(l1,l2,cb,
            Arrow(DOWN*2,UP*2),
            Arrow(LEFT*4,RIGHT*4).move_to(cb.point_from_proportion(0.5))

        )
        self.wait()

class p3(MovingCameraScene):
    def construct(self):
        # self.camera.frame.save_state()
        # self.add(NumberPlane())
        # self.camera.frame.rotate(13*DEGREES,about_point=[0.0, 0.0, 1.0])
        l1=Line(UP*2,DOWN*2).set_stroke(width=30).shift(LEFT*0.15).set_color(LV)
        l2=Line(UP*2,DOWN*2).set_stroke(width=30).shift(RIGHT*0.15).set_color(LV)
        l0=Line(LEFT*4,RIGHT*4).shift(DOWN*2).set_color(JH)
        da=DoubleArrow(LEFT*3,RIGHT*3,tip_shape_start=LineTip,tip_shape_end=LineTip).next_to(l0,DOWN)
        cb=CubicBezier(l1.get_top(),[-0.2,-2,0],[0.2,-2,0],l2.get_top()).set_color(JH)
        da_20=DoubleArrow(cb.point_from_proportion(0.5),l0.get_center(),tip_shape_start=LineTip,tip_shape_end=LineTip)
        self.add(l1,l2,cb,da_20,
            MathTex('50m').next_to(l1,LEFT,buff=0.3),
            MathTex('20m').next_to(da_20)

        )
        self.wait()